<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="author" content="纪德朝">
    <title>模拟select</title>
    <style>
    body{
        width: 100%;
        height: 1000px;
    }
    div{
        width: 200px;
        margin: 0 auto;
        text-align: center;
        display: flex;
        position:relative;
    }
    ul,li{
        margin: 0;
        padding: 0;
        list-style: none;
    }
    p{
        display: inline-block;
        width: 100px;
        margin: 0;
        padding: 0;
        height: 40px;
        background-color: green;
        line-height: 40px;
    }
    div>li{
        width: 100px;
        height: 40px;
        line-height: 40px;
        background-color: gray;
    }
    .active{
        border: 1px solid black;
        border-bottom: none;
        position: absolute;
        top: 40px;
        left: 100px;
         display: none; 
    }
    .active li{
        width: 100px;
        height: 30px;
        line-height: 30px;
        border-bottom: 1px solid black;
    }
    </style>
</head>
<body>
    <div>
        <p>选择项目：</p>
        <li class="current">未选择</li>
        <ul class="active">
            <li>html</li>
            <li>css</li>
            <li>js</li>
            <li>jq</li>
        </ul>        
    </div>
    <script src="./js/jquery.js"></script>
</body>
<script>
    $('.current').click(function(ev){
        $('.active').css('display','block');
        ev.stopPropagation();
        $('.active li').click(function(){
            $('.current').text($(this).html());
            $('.active').css('display','none');
        })
    })
    $('body').click(function(){
        // console.log(123);
        if($('.active').css('display','block')){
            
            $('.active').css('display','none');
        }
    })
</script>
</html>